package nine;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.security.KeyStore;
import java.util.*;

public class MiMa {
    static int[] ch = new int[26];
    static Scanner sc = new Scanner(System.in);
    static String st = sc.nextLine();
    static int[] arr = new int[st.length()];
    static int[] arr1 = new int[st.length()];

    public static void main(String[] args) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        chushi();
        jiami();
        for (int i = 0; i < arr.length; i++) {
            stringBuilder.append(st.charAt(arr1[i]-1));
        }
        String str = stringBuilder.toString();
        shu(str);
        //txt文件路径绝对路径
        BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter("C:\\Users\\lenovo\\IdeaProjects\\shixun\\src\\nine\\MI"));
        bufferedWriter.write(str);
        bufferedWriter.close();
    }

    static void chushi() {
        for (int i = 0; i < st.length(); i++) {
            arr[i] = i + 1;
        }
    }


    static void jiami() {
        //第一个加密
        for (int i = 0; i < arr.length - 1; i++) {
            tihuan(i, i + 1);
        }
        tihuan(arr.length - 1, 0);
        //第二次加密
       // for (int i = 0; i < arr.length - 3; i++) {
        //    tihuan1(i, i + 3);
       // }
       // tihuan1(arr.length - 3, 0);
       // tihuan1(arr.length - 2, 1);
        //tihuan1(arr.length - 1, 2);
        //第三次加密
       // tihuan(0, arr.length - 1);
        //for (int i = 1; i < arr.length; i++) {
          //  tihuan(i, i - 1);
       // }
        //第三次加密
       // tihuan1(0, arr.length - 1);
       // tihuan1(1, arr.length - 2);
        //for (int i = 2; i < arr.length; i++) {
         //   tihuan1(i, i - 2);
       // }
    }

    static void tihuan(int a, int b) {
        arr1[a] = arr[b];
    }

    static void tihuan1(int a, int b) {
        arr[a] = arr1[b];
    }

    static void shu(String str) {
        Map<String, String> map = new HashMap<String, String>();
        for (int i = 0; i < st.length(); i++) {
            char q = str.charAt(i);
            if (q <= 'Z' && q >= 'A') {
                ch[q - 65]++;
            } else {
                ch[q - 97]++;
            }
        }
        for (int i=0;i<ch.length;i++){
            map.put(""+(char)(i+65),""+ch[i]);
        }
        List<Map.Entry<String, String>> list = new ArrayList<Map.Entry<String, String>>(map.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<String, String>>() {
            //升序排序
            @Override
            public int compare(Map.Entry<String, String> o1,
                               Map.Entry<String, String> o2) {
                return o2.getValue().compareTo(o1.getValue());
            }

        });
        for (Map.Entry<String, String> mapping : list) {
            System.out.println("字母为"+mapping.getKey() + "出现次数" + mapping.getValue());
        }
    }
}

